package cn.stylefeng.guns.modular.jhb.controller;

import cn.stylefeng.guns.modular.jhb.pojo.request.JhbRequest;
import cn.stylefeng.guns.modular.jhb.service.JhbService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 班次计划表控制器
 *
 * @author zhu
 * @date 2021/10/06 11:17
 */
@RestController
@ApiResource(name = "班次计划表")
public class JhbController {

    @Resource
    private JhbService jhbService;

    /**
     * 添加
     *
     * @author zhu
     * @date 2021/10/06 11:17
     */
    @PostResource(name = "添加", path = "/jhb/add")
    public ResponseData add(@RequestBody @Validated(JhbRequest.add.class) JhbRequest jhbRequest) {
        jhbService.add(jhbRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhu
     * @date 2021/10/06 11:17
     */
    @PostResource(name = "删除", path = "/jhb/delete")
    public ResponseData delete(@RequestBody @Validated(JhbRequest.delete.class) JhbRequest jhbRequest) {
        jhbService.del(jhbRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhu
     * @date 2021/10/06 11:17
     */
    @PostResource(name = "编辑", path = "/jhb/edit")
    public ResponseData edit(@RequestBody @Validated(JhbRequest.edit.class) JhbRequest jhbRequest) {
        jhbService.edit(jhbRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhu
     * @date 2021/10/06 11:17
     */
    @GetResource(name = "查看详情", path = "/jhb/detail")
    public ResponseData detail(@Validated(JhbRequest.detail.class) JhbRequest jhbRequest) {
        return new SuccessResponseData(jhbService.detail(jhbRequest));
    }

    /**
     * 获取列表
     *
     * @author zhu
     * @date 2021/10/06 11:17
     */
    @GetResource(name = "获取列表", path = "/jhb/list")
    public ResponseData list(JhbRequest jhbRequest) {
        return new SuccessResponseData(jhbService.findList(jhbRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhu
     * @date 2021/10/06 11:17
     */
    @GetResource(name = "分页查询", path = "/jhb/page")
    public ResponseData page(JhbRequest jhbRequest) {
        return new SuccessResponseData(jhbService.findPage(jhbRequest));
    }

}